package com.chd.driversystem.util.test;

import android.graphics.Bitmap;

import com.chd.driversystem.domain.Assignment;
import com.chd.driversystem.domain.DrivingRecord;
import com.chd.driversystem.domain.Evaluation;
import com.chd.driversystem.domain.Locations;
import com.chd.driversystem.domain.Oil;
import com.chd.driversystem.domain.Operation;
import com.chd.driversystem.domain.Team;
import com.chd.driversystem.domain.User;
import com.chd.driversystem.domain.Vehicle;
import com.chd.driversystem.util.tools.MyApplication;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * Created by feiyu on 17-5-8.
 */

public class GetTestData {
    private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    private static Random random = new Random();

    public static User getOneUser(String loginname, String password, boolean isManager) {
        User user = null;
        try {
            user = new User(null,
                    "陈海",
                    loginname,
                    password,
                    isManager,
                    1L,
                    "+86", "18629626701",
                    null,
                    null,
                    false,
                    dateFormat.parse("2000-12-02"), 1L);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return user;
    }

    public static DrivingRecord getOneDrivingRecord(Date date) {
        return new DrivingRecord(
                null,
                MyApplication.getUser().getId(),
                date,
                random.nextInt(1000),
                1000 + random.nextInt(9000),
                random.nextInt(100),
                71 + random.nextInt(30),
                random.nextInt(7),
                random.nextInt(24),
                random.nextInt(3),
                random.nextInt(1)
        );
    }


    public static Oil getOil(Date date) {
        return new Oil(null,
                MyApplication.getUser().getId(),
                date,
                random.nextDouble() * 100,
                random.nextDouble() * 100,
                random.nextDouble() * 3000,
                random.nextDouble() * 100);
    }


    public static List<Evaluation> getEvaluations(Long userId, Integer type) {
        List<Evaluation> evaluations = new ArrayList<>();
        try {
            for (int i = 1; i < 31; i++) {
                String str = "";
                if (i < 10) {
                    str = "0";
                }

                Evaluation evaluation = new Evaluation(null, userId, type, dateFormat.parse("2001-12-" + str + i), 41 + random.nextInt(60),
                        20 + random.nextInt(81), 35 + random.nextInt(66), 77 + random.nextInt(24), 55 + random.nextInt(46), 40 + random.nextInt(61),
                        46 + random.nextInt(55));
                evaluations.add(evaluation);
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return evaluations;
    }

    public static List<User> getUserListByManagerId(Long managerId, List<User> users, List<String> usercodes) {
        User user;
        try {
            for (int i = 0; i < usercodes.size(); i++) {
                user = new User(null,
                        "用户" + i,
                        usercodes.get(i),
                        null,
                        false,
                        managerId,
                        "+86", "18629626701",
                        null,
                        null,
                        false,
                        dateFormat.parse("2000-12-02"),
                        1L);
                users.add(user);
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return users;
    }

    public static List<Evaluation> getEvaluationsByUserList(List<User> users, Integer type) {
        List<Evaluation> evaluations = new ArrayList<>();
        for (User user : users) {
            Evaluation evaluation = new Evaluation(
                    null,
                    user.getId(),
                    type,
                    new Date(),
                    random.nextInt(60),
                    20 + random.nextInt(81),
                    35 + random.nextInt(66),
                    77 + random.nextInt(24),
                    55 + random.nextInt(46),
                    40 + random.nextInt(61),
                    46 + random.nextInt(55));
            evaluations.add(evaluation);
        }
        return evaluations;
    }
}
